﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TinyCinema.UI.Pages.Schedule._Deal._NewDeal
{
    /// <summary>
    /// Interaction logic for CheckOut.xaml
    /// </summary>
    public partial class CheckOut : Page
    {
        public static DependencyProperty IDCheckingStatusProperty = DependencyProperty.Register("IDCheckingStatus", typeof(string), typeof(CheckOut));
        public string IDCheckingStatus
        {
            get { return (string)GetValue(IDCheckingStatusProperty); }
            set { SetValue(IDCheckingStatusProperty, value); }
        }
        public CheckOut()
        {
            InitializeComponent();
            Loaded += CheckOut_Loaded;
            (DataContext as Bussiness.Schedule.Schedule).Messenger.Register<Bussiness.Schedule.Message.CustmomerIDFound>(this, ShowMessageBox1);
            (DataContext as Bussiness.Schedule.Schedule).Messenger.Register<Bussiness.Schedule.Message.CustmomerIDNotFound>(this, ShowMessageBox2);
            (DataContext as Bussiness.Schedule.Schedule).Messenger.Register<Bussiness.Schedule.Message.PayCancelConfirmation>(this, ShowMessageBox3);
            (DataContext as Bussiness.Schedule.Schedule).Messenger.Register<Bussiness.Schedule.Message.PayCancelConfirmationOK>(this, ShowMessageBox4);
            (DataContext as Bussiness.Schedule.Schedule).Messenger.Register<Bussiness.Schedule.Message.PayConfirmation>(this, ShowMessageBox5);
            (DataContext as Bussiness.Schedule.Schedule).Messenger.Register<Bussiness.Schedule.Message.PayConfirmationOK>(this, (s) =>
                {
                    (new Tickets()).ShowDialog();
                });
        }

        void CheckOut_Loaded(object sender, RoutedEventArgs e)
        {
            (DataContext as Bussiness.Schedule.Schedule).ValueCount();
        }

        private void Back(object sender, RoutedEventArgs e)
        {
            Deal.pagNewDeal.pagContentFrameSource = NewDeal.pagSelectDesk;
        }
        void ShowMessageBox1(Bussiness.Schedule.Message.CustmomerIDFound s)
        {
            IDCheckingStatus = (App.Current.FindResource("langMsgIDCheckingYes") as String);
        }
        void ShowMessageBox2(Bussiness.Schedule.Message.CustmomerIDNotFound s)
        {
            IDCheckingStatus = (App.Current.FindResource("langMsgIDCheckingNo") as String);
        }
        void ShowMessageBox3(Bussiness.Schedule.Message.PayCancelConfirmation s)
        {
            s.Result = MessageBoxUtils.WPFMessageBox.Show((App.Current.FindResource("langMsgDealCancel") as String), "", MessageBoxButton.YesNo);
        }
        void ShowMessageBox4(Bussiness.Schedule.Message.PayCancelConfirmationOK s)
        {
            Deal.pagNewDeal.pagContentFrameSource = NewDeal.pagSelectSchedule;
        }
        void ShowMessageBox5(Bussiness.Schedule.Message.PayConfirmation s)
        {
            s.Result = MessageBoxUtils.WPFMessageBox.Show((App.Current.FindResource("langMsgDealPay") as String), "", MessageBoxButton.YesNo);
        }
        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
           (DataContext as Bussiness.Schedule.Schedule).CheckCustomerIDCommand.Execute((sender as TextBox).Text);
        }
    }
}
